// stores/consult.ts
import { ref } from 'vue'
import { defineStore } from 'pinia'
import type { ConsultInfo } from '@/types/patient'

// 患者ID
const patientId = ref('')
const setPatientId = (id: string) => {
  patientId.value = id
}

export const useConsultStore = defineStore(
  'consult',
  () => {
    // 患者病情初始数据

       // 医生id
    const docId = ref('')
    const setDocId = (id: string) => {
      docId.value = id
    }
    // 科室id
    const depId = ref('')
    const setDepId = (id: string) => {
      depId.value = id
    }
    // 极速问诊级别 0 普通 1 三甲
    const illnessType = ref('')
    const setIllnessType = (value: string) => {
      illnessType.value = value
    }
    const initValue = {
      illnessDesc:'',
      illnessTime:1,
      consultFlag:0,
      pictures:[]
    }
    // 患者病情数据
    const illnessInfo = ref<ConsultInfo>({
      ...initValue
    })
    // 重置数据
    const clear = ()=>{
      depId.value = ''
      type.value = ''
      patientId.value = ''
      illnessType.value = ''
      illnessInfo.value = { ...initValue}
    }
    const setIllnessInfo = (obj: ConsultInfo) => {
      illnessInfo.value = obj
    }
    // 问诊类型  1 找医生  2 极速问诊  3 图文问诊
    const type = ref('')
    const setType = (value: string) => {
      type.value = value
    }

    return {
      clear,
      illnessInfo,
      setIllnessInfo,
      patientId,
      setPatientId,
      depId,
      setDepId,
      illnessType,
      setIllnessType,
      type,
      setType,
    }
  },
  {
    unistorage: true,
  }
)
